package interfaces.subpanel.summaryinfo.gui;

import java.awt.Color;
import java.awt.Component;

import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.ListCellRenderer;

public class ResultSummaryCellRenderer extends JLabel implements ListCellRenderer {

	private static final long serialVersionUID = 1L;

	private static final Color HIGHLIGHT_COLOR = new Color(0, 0, 128);

	private ImageIcon icon;

	public ResultSummaryCellRenderer(ImageIcon icon) {
		setOpaque(true);
		setIconTextGap(12);
		this.icon = icon;
	}

	public Component getListCellRendererComponent(JList list, Object value,
			int index, boolean isSelected, boolean cellHasFocus) {
		ResultSummaryEvaluation entry = (ResultSummaryEvaluation) value;
		setText(entry.getTitle());
		setIcon(icon);
		if (isSelected) {
			setBackground(HIGHLIGHT_COLOR);
			setForeground(Color.white);
		} else {
			setBackground(Color.white);
			setForeground(Color.black);
		}
		return this;
	}
}